<template>
	<view class="shop-nav-bar">
		<view class="status-bar"> </view>
		<view class="nav">
			<view class="left"> 
				<image src="/static/icon/navbar/left.png" @tap="leftTap" class="left"/>
			</view>
			<view class="center"> {{ title }} </view>
			<view class="right" @tap="rightTap"> 
				<view class="text" v-if="rightText"> {{ rightText }} </view>
				<image v-if="rightIcon" src="/static/icon/cart/search.png" class="r-img"/>
			</view>
		</view>
	</view>
</template>

<script setup>
	const emit = defineEmits(['rightTap'])
	defineProps({
		title: {
			type: String,
			default: ''
		},
		rightText: {
			type: String,
			default: ''
		},
		rightIcon: {
			type: Boolean,
			default: false
		}
	})
	const leftTap = () => {
		uni.navigateBack()
	}
	const rightTap = () => {
		emit('rightTap')
	}
</script>

<style lang="scss" scoped>
	.shop-nav-bar {
		position: sticky;
		top: 0;
		left: 0;
		right: 0;
		z-index: 999;
		background-color: #F4F5F7;
		.status-bar {
			height: var(--status-bar-height);
			width: 100%;
		}
		.nav {
			height: 44px;
			padding: 0 12px;
			display: flex;
			align-items: center;
			justify-content: space-between;
			.left {
				width: 16px;
				height: 16px;
				display: flex;
				align-items: center;
				justify-content: center;
			}
			.center {
				font-size: 16px;
				font-weight: 500;
			}
			.right {
				min-width: 16px;
				.text {
					color: #333333;
					font-size: 14px;
					font-weight: 400;
				}
				.r-img {
					width: 16px;
					height: 16px;
				}
			}
		}
	}
</style>